/***************************************
* @update: 2021-04-20  hby		  [创建文件,编写功能]
* @update: 2021-05-11  LiLinBin   [将路由配置信息提取成配置文件]
*
* @description: 路由功能
 ***************************************/


import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import config from './config'



const router = createRouter({
	// history: createWebHistory(),
	history: createWebHashHistory(),
	routes: config
})



router.beforeEach(async (to, from, next) => {
	if (to.name === 'inactivePage' || to.name === 'login') {
		next()
		return
	}

	if (to.path.indexOf('/system') === 0) {
		const loginInfo = JSON.parse(localStorage.getItem('checkLogin') || "{}")
		if (!loginInfo.pass) {
			next({ name: 'login' })
			return
		}
	}

	next()
})



export default router